package cn.tm.ms.memory.ds.support;

import java.util.Map;
import java.util.Properties;

import javax.sql.DataSource;

import cn.tm.ms.memory.common.Constants;
import cn.tm.ms.memory.common.PropLoader;
import cn.tm.ms.memory.ds.Ids;

import com.alibaba.druid.pool.DruidDataSourceFactory;

/**
 * Druid数据源
 * 
 * @author lry
 */
public class IdsDruid implements Ids {

	public DataSource getDataSource() throws Throwable {
		PropLoader propLoader=new PropLoader().loader(Constants.DRUID_NAME);
		return DruidDataSourceFactory.createDataSource(propLoader.getProperties());
	}
	
	public DataSource getDataSource(String propertiesName) throws Throwable {
		PropLoader propLoader=new PropLoader().loader(propertiesName);
		return DruidDataSourceFactory.createDataSource(propLoader.getProperties());
	}
	
	public DataSource getDataSource(Map<String,Object> properties) throws Throwable {
		return DruidDataSourceFactory.createDataSource(properties);
	}
	
	public DataSource getDataSource(Properties properties) throws Throwable {
		return DruidDataSourceFactory.createDataSource(properties);
	}

}
